﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;
using Entity;

namespace Controller
{
    public class CategoryController:ControllerBase
    {
        public IList<CategoryEntity> FindAllCategory()
        {
            IList<Category> categories = (from c in Sdc.Categories
                                          select c).ToList();
            IList<CategoryEntity> categoryEntities=new List<CategoryEntity>();
            foreach (Category category in categories)
            {
                CategoryEntity categoryEntity = TransformCategoryToCategoryEntity(category);
                categoryEntities.Add(categoryEntity);
            }
            return categoryEntities;
        }

        public static CategoryEntity TransformCategoryToCategoryEntity(Category category)
        {
            CategoryEntity categoryEntity=new CategoryEntity();
            categoryEntity.Id = category.Id;
            categoryEntity.Name = category.Name;
            categoryEntity.Description = category.Description;
            return categoryEntity;
        }

    }
}
